Auth()
//从登录注册页面跳转首页
var typeId = globalFun.GetQueryString('type');
if(typeId == 1) {
	$('#vl_active').addClass('click');
	$('#vl_active').siblings().removeClass('click');
	$('#vl_active_xq').css('display', 'block');
	$('#vl_active_xq').siblings().css('display', 'none');
} else if(typeId == 2) {
	$('#vl_team').addClass('click');
	$('#vl_team').siblings().removeClass('click');
	$('#vl_team_xq').css('display', 'block');
	$('#vl_team_xq').siblings().css('display', 'none');
}

//点击切换列表
$('#vl_active').on('click', function() {
	$(this).addClass('click');
	$(this).siblings().removeClass('click')
	$('#vl_active_xq').css('display', 'block');
	$('#vl_active_xq').siblings().css('display', 'none');
});
$('#vl_team').on('click', function() {
	$(this).addClass('click');
	$(this).siblings().removeClass('click')
	$('#vl_team_xq').css('display', 'block');
	$('#vl_team_xq').siblings().css('display', 'none');
});
$('#vl_integral').on('click', function() {
	$(this).addClass('click');
	$(this).siblings().removeClass('click')
	window.location.href = 'volunteer_integral.html'
});
//点击跳转团队详情
$("#vl_tean_mian").on('click', '.vl_team_xq', function() {
	var teamId = $(this).attr('data-id')
	window.location.href = 'detail_team.html?teamId=' + teamId
})
//活动列表跳转
$("#vl_active_xq").on('click', '.vl_active_xq', function() {
	var activeId = $(this).attr('data-id')
	window.location.href = 'detail_active.html?activeId=' + activeId
})
//热门活动跳转
$("#m_right").on('click', '.hot_main', function() {
	var activeId = $(this).attr('htId')
	window.location.href = 'detail_active.html?activeId=' + activeId
})
//活动区域筛选
var areaId="";
$('.h_address').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	areaId = $(this).attr('data-id')
	hdList(1,areaId,aimType,activityType,true)
})
var activityType="";
$('.h_type').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	activityType = $(this).attr('data-id');
	console.log(activityType);
	hdList(1,areaId,aimType,activityType,true)
})
var aimType="";
$('.h_people').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	aimType = $(this).attr('data-id');
	console.log(aimType);
	hdList(1,areaId,aimType,activityType,true)
	tmList(1, areaId, activityType, true)
})
var t_areaId="";
$('.t_address').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	t_areaId = $(this).attr('data-id')
	tmList(1, t_areaId, activityType, supervisorType, true)
})
var serviceType="";
$('.t_type').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	serviceType = $(this).attr('data-id');
	console.log(activityType);
	tmList(1, t_areaId, serviceType, supervisorType, true)
})
var supervisorType="";
$('.team_type').on('click', 'span', function() {
	$(this).addClass('choose');
	$(this).siblings().removeClass('choose');
	supervisorType = $(this).attr('data-id');
	console.log(supervisorType);
	tmList(1, t_areaId, serviceType, supervisorType, true)
	
})
//获取服务区域
$.ajax({
	type: "post",
	url: apicom + "/area/getAreaInfo",
	async: true,
	success: function(res) {
		var data = res.data;
		var ss = '';
		for(var i = 0; i < data.length; i++) {
			ss += '<span data-id="' + data[i].id + '">' + data[i].name + '</span>'
		}
		$(".h_address").append(ss);
		$(".t_address").append(ss);
	},
	error: function(err) {

	}
});
//活动列表----------------------------------------------------------
hdList(1,areaId,aimType,activityType,true)
function hdList(page, areaId, aimType, activityType, init) {
	var hdObj = {
		activityType: activityType,
		aimType: aimType,
		areaId: areaId,
		pageNum: page,
		pageSize: 5,
	}
	$.ajax({
		type: "post",
		url: apicom + '/activity/getActivityList',
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
//			console.log(res)
			if(res.code == 200) {
//				console.log(res)
				var dataScourse = res.data;
				if(dataScourse.length == 0) {
					$(".com_page").hide();
					jiegou(dataScourse);
//					$('#vl_active_mian').html("<div class='center_kong'><img src='../img/f_2.png'/><p>活动为空！</p></div>");
					return false;
				}
				jiegou(dataScourse);
				$(".com_page").show();
				all_num = res.pages;
				/* 分页 */
				if(init == true){
					$(".com_page").createPage({
						pageNum: all_num, //总页码
						current: 1, //当前页
						shownum: 7, //每页显示个数
						showPageNum: false, //显示总页数
						showToPage: false, //显示跳转页码
						backfun: function(e) {
							hdList(e.current,areaId,aimType,activityType, false);
						}
					});
				}
			} else {
//				tips('暂无活动')
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}
//团队列表----------------------------------------------------------
tmList(1, t_areaId, serviceType,supervisorType, true)
function tmList(page, t_areaId, serviceType, supervisorType, init) {
	var hdObj = {
		serviceType: serviceType,
		supervisorType: supervisorType,
		areaId: t_areaId,
		pageNum: page,
		pageSize: 5,
	}
	$.ajax({
		type: "post",
		url: apicom + '/team/getTeamList',
		async: true,
		data: hdObj,
		success: function(res) {
			if(typeof res == 'string') {
				res = JSON.parse(res);
			}
//			console.log(res)
			if(res.code == 200) {
//				console.log(res)
				var dataScourse = res.data;
				if(dataScourse.length == 0) {
					$(".com_page1").hide();
					jiegou1(dataScourse);
//					$('#vt_active_mian').html("<div class='center_kong'><img src='../img/f_2.png'/><p>活动为空！</p></div>");
					return false;
				}
				jiegou1(dataScourse);
				$(".com_page1").show();
				all_num = res.pages;
//				/* 分页 */
				if(init == true){
					$(".com_page1").createPage({
						pageNum: all_num, //总页码
						current: 1, //当前页
						shownum: 7, //每页显示个数
						showPageNum: false, //显示总页数
						showToPage: false, //显示跳转页码
						backfun: function(e) {
							tmList(e.current,t_areaId,serviceType,supervisorType, false);
						}
					});
				}
			} else {
//				tips('暂无团队')
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}


//热门活动列表
var all_num;
var page_unm = 1;
function hotList(page) {
	var hdObj = {
		pageNum: page,
		pageSize: 4,
	}
	$.ajax({
		type: "post",
		url: apicom + '/activity/getHotActivityList',
		async: true,
		data: hdObj,
		success: function(res) {
			console.log(res)
			if(res.code == 200) {
				all_num = res.pages;
				var content = res.data;
				var ss = ''
				for(var i = 0; i<content.length; i++){
					ss+='<div class="hot_main" htId="'+content[i].id+'">'
					ss+='<p class="hot_img"><img class="img3" src="'+content[i].imgUrl+'"/></p>'	
					ss+='<dl class="hot_main_xq">'	
					ss+='<dt>'+content[i].title+'</dt>'		
					ss+='<dd>时间：'+content[i].beginTime+'</dd></dl></div>'	
				};
			$('.hot_xq').html(ss);
			}
		},
		error: function(err) {
			console.log(err)
		}
	})
}
hotList(page_unm);
//上一页
	$('#prve').on('click',function(){
			page_unm--
			console.log(page_unm)
			if(page_unm<1){
				page_unm = 1
				hotList(page_unm)
			}else{
				hotList(page_unm)
			}
	})
//下一页
	$('#next').on('click',function(){
			
			console.log(page_unm);
			if(page_unm=>all_num){
				page_unm = all_num
				hotList(all_num);
			}else{
				page_unm++
				hotList(page_unm);
			}
		
	})
//活动数据渲染
function jiegou(content) {
	var ss = '';
	for(var i = 0; i < content.length; i++) {
		ss += '<div class="vl_active_xq" data-id="' + content[i].id + '">'
		ss += '<img class="img1" src="' + content[i].imgUrl + '"/>'
		ss += '<dl class="dl_xq">'
		ss += '<dt>' + content[i].title + '</dt>'
		ss += '<dd class="address">' + content[i].teamName + '</dd>'
		ss += '<dd class="timer"><img src="img/icon_sj.png"/><span>' + content[i].createdTime + '</span></dd><dd class="timer1"><img class="img2" src="img/icon_ll.png"/><span>' + content[i].browserAmount + '</span><img class="img2" src="img/icon_dz.png"/><span>' + content[i].fabulousNum + '</span><img class="img2" src="img/icon_sc.png"/><span>' + content[i].collectionNum + '</span></dd>'
		ss += '</dl></div>'
	}
	$('#vl_active_mian').html(ss);
}
//团队数据渲染
function jiegou1(content) {
	var ss = '';
	for(var i = 0; i < content.length; i++) {
		ss += '<div class="vl_team_xq" data-id="' + content[i].teamId + '">'
		ss += '<img class="img1" src="' + content[i].image + '"/>'
		ss += '<dl class="dl_xq">'
		ss += '<dt>' + content[i].name + '</dt>'
		ss += '<dd class="timer"><img src="img/icon_sj.png"/><span>' + content[i].createdTime + '</span></dd><dd class="timer1"><img class="img2" src="img/icon_ll.png"/><span>' + content[i].browserAmount + '</span><img class="img2" src="img/icon_dz.png"/><span>0</span><img class="img2" src="img/icon_sc.png"/><span>0</span></dd>'
		ss += '</dl></div>'
	}
	$('#vl_tean_mian').html(ss);
}
